package com.aabte.commons.errorcode;

import com.aabte.commons.errorcode.exception.BaseException;
import com.aabte.commons.errorcode.exception.BusinessException;

/**
 * @author Daniel
 */
public interface BusinessExceptionAssert extends Assert, IResponseCode {

  @Override
  default BaseException newException(Object... args) {
    return new BusinessException(this, this.message(), args);
  }

  @Override
  default BaseException newException(String message, Object... args) {
    if (null == message || message.length() == 0) {
      message = this.message();
    }
    return new BusinessException(this, message, args);
  }

  @Override
  default BaseException newException(Throwable t, Object... args) {
    return new BusinessException(this, this.message(), args, t);
  }

  @Override
  default BaseException newException(Throwable t, String message, Object... args) {
    if (null == message || message.length() == 0) {
      message = this.message();
    }
    return new BusinessException(this, message, args, t);
  }

}
